```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>深入解析聚簇索引与非聚簇索引 | 技术小馆</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.8;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight-box {
            border-left: 4px solid #6e8efb;
            background-color: rgba(110, 142, 251, 0.05);
        }
        .comparison-table th {
            background-color: #f8fafc;
        }
        .mermaid {
            background-color: white;
            border-radius: 0.5rem;
            padding: 1.5rem;
            margin: 2rem 0;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        .image-container {
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
            border-radius: 0.5rem;
            overflow: hidden;
            margin: 2rem 0;
            transition: all 0.3s ease;
        }
        .image-container:hover {
            transform: translateY(-3px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .image-caption {
            background-color: #f8fafc;
            padding: 0.75rem 1rem;
            font-size: 0.875rem;
            color: #64748b;
            text-align: center;
            border-top: 1px solid #e2e8f0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <header class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6 max-w-6xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-2/3">
                    <h1 class="text-4xl md:text-5xl font-bold leading-tight mb-4">深入解析数据库索引</h1>
                    <h2 class="text-2xl md:text-3xl font-semibold mb-6">聚簇索引与非聚簇索引的全面指南</h2>
                    <p class="text-xl opacity-90 mb-8">探索两种核心索引类型的原理、差异及最佳实践，提升你的数据库性能优化能力</p>
                    <div class="flex flex-wrap gap-4">
                        <a href="#definition" class="bg-white text-indigo-600 hover:bg-gray-100 px-6 py-3 rounded-full font-medium transition-all duration-300">
                            <i class="fas fa-book-open mr-2"></i>立即学习
                        </a>
                        <a href="#comparison" class="border-2 border-white text-white hover:bg-white hover:text-indigo-600 px-6 py-3 rounded-full font-medium transition-all duration-300">
                            <i class="fas fa-balance-scale mr-2"></i>对比分析
                        </a>
                    </div>
                </div>
                <div class="hidden md:block md:w-1/3 mt-10 md:mt-0">
                    <div class="relative">
                        <div class="absolute -top-10 -left-10 w-32 h-32 bg-purple-300 rounded-full opacity-20"></div>
                        <div class="absolute -bottom-10 -right-10 w-32 h-32 bg-blue-300 rounded-full opacity-20"></div>
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1712202881934-b48d5411-1b75-48af-9d01-94a779b87c7c.png" alt="数据库索引概念图" class="relative z-10 rounded-lg shadow-2xl">
                    </div>
                </div>
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12 max-w-6xl">
        <!-- Introduction -->
        <section id="introduction" class="mb-16">
            <div class="mb-8">
                <span class="inline-block px-3 py-1 bg-blue-100 text-blue-600 rounded-full text-sm font-semibold mb-4">数据库优化</span>
                <h2 class="text-3xl font-bold text-gray-800 mb-4">什么是聚簇索引和非聚簇索引？</h2>
                <p class="text-lg text-gray-600 mb-6">当谈到数据库索引时，我们经常会听到聚簇索引和非聚簇索引这两个术语。它们是数据库中常用的两种索引类型，对于数据库设计和性能优化至关重要。</p>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white p-6 rounded-xl shadow-md card-hover transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-4">
                            <i class="fas fa-sitemap text-blue-500 text-lg"></i>
                        </div>
                        <h3 class="text-xl font-semibold text-gray-800">聚簇索引</h3>
                    </div>
                    <p class="text-gray-600">按照表的主键顺序组织数据的索引结构，数据行的物理存储顺序与索引逻辑顺序一致，查询效率极高但一个表只能有一个。</p>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-md card-hover transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-full bg-purple-100 flex items-center justify-center mr-4">
                            <i class="fas fa-project-diagram text-purple-500 text-lg"></i>
                        </div>
                        <h3 class="text-xl font-semibold text-gray-800">非聚簇索引</h3>
                    </div>
                    <p class="text-gray-600">独立于表数据组织方式的索引结构，索引键值与数据行存储顺序无关，可以有多个但查询时可能需要额外的查找步骤。</p>
                </div>
            </div>
        </section>

        <!-- Definition Section -->
        <section id="definition" class="mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 border-l-4 border-blue-500 pl-4">定义解析</h2>
            
            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div>
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-blue-100 flex items-center justify-center mr-4">
                            <i class="fas fa-sitemap text-blue-500 text-xl"></i>
                        </div>
                        <h3 class="text-2xl font-semibold text-gray-800">聚簇索引 (Clustered Index)</h3>
                    </div>
                    <p class="text-gray-600 mb-4">聚簇索引是按照表的主键顺序来组织数据的一种索引结构。具体来说，聚簇索引会按照主键的值对数据行进行排序并存储。</p>
                    <div class="highlight-box p-4 mb-4">
                        <p class="font-medium">关键特性：</p>
                        <ul class="list-disc pl-5 space-y-1 mt-2">
                            <li>数据行的物理存储顺序与索引的逻辑顺序一致</li>
                            <li>一个表只能有一个聚簇索引</li>
                            <li>主键查询效率非常高</li>
                            <li>数据行存储在索引的叶子节点中</li>
                        </ul>
                    </div>
                </div>
                
                <div class="image-container">
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1712203185399-1f2be62c-e968-43b1-b6f8-08394c5e38bf.png" alt="聚簇索引结构图" class="w-full">
                    <div class="image-caption">聚簇索引结构示意图</div>
                </div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="order-2 md:order-1">
                    <div class="image-container">
                        <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1653815929512-c5ea9f64-bda9-4726-a0b3-ebe5d2184956.png?x-oss-process=image%2Fresize%2Cw_631%2Climit_0%2Fresize%2Cw_631%2Climit_0%2Fformat%2Cwebp%2Fresize%2Cw_631%2Climit_0" alt="非聚簇索引结构图" class="w-full">
                        <div class="image-caption">非聚簇索引结构示意图</div>
                    </div>
                </div>
                
                <div class="order-1 md:order-2">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-purple-100 flex items-center justify-center mr-4">
                            <i class="fas fa-project-diagram text-purple-500 text-xl"></i>
                        </div>
                        <h3 class="text-2xl font-semibold text-gray-800">非聚簇索引 (Non-Clustered Index)</h3>
                    </div>
                    <p class="text-gray-600 mb-4">非聚簇索引是一种独立于表数据组织方式的索引结构。在非聚簇索引中，索引的叶子节点保存了指向对应数据行的指针。</p>
                    <div class="highlight-box p-4">
                        <p class="font-medium">关键特性：</p>
                        <ul class="list-disc pl-5 space-y-1 mt-2">
                            <li>索引键值与数据行存储顺序无关</li>
                            <li>一个表可以有多个非聚簇索引</li>
                            <li>查询时需要额外的查找步骤</li>
                            <li>叶子节点保存的是数据行的指针</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- Features Section -->
        <section id="features" class="mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 border-l-4 border-blue-500 pl-4">核心特点</h2>
            
            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div>
                    <h3 class="text-2xl font-semibold text-gray-800 mb-4 flex items-center">
                        <span class="w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center mr-3">
                            <i class="fas fa-check text-blue-500"></i>
                        </span>
                        聚簇索引特点
                    </h3>
                    <div class="space-y-4">
                        <div class="p-4 bg-white rounded-lg shadow-sm">
                            <p class="font-medium text-gray-800">数据存储方式</p>
                            <p class="text-gray-600 mt-1">数据行的物理存储顺序与索引的逻辑顺序一致。表中的数据实际上是按照主键的值顺序组织的。</p>
                        </div>
                        <div class="p-4 bg-white rounded-lg shadow-sm">
                            <p class="font-medium text-gray-800">查询效率</p>
                            <p class="text-gray-600 mt-1">对于主键查询非常高效，数据库可以直接根据主键值找到对应的数据行，无需进行额外的查找操作。</p>
                        </div>
                        <div class="p-4 bg-white rounded-lg shadow-sm">
                            <p class="font-medium text-gray-800">数量限制</p>
                            <p class="text-gray-600 mt-1">一个表只能有一个聚簇索引，通常是由数据库系统自动为表的主键创建的。</p>
                        </div>
                    </div>
                </div>
                
                <div>
                    <h3 class="text-2xl font-semibold text-gray-800 mb-4 flex items-center">
                        <span class="w-8 h-8 bg-purple-100 rounded-full flex items-center justify-center mr-3">
                            <i class="fas fa-check text-purple-500"></i>
                        </span>
                        非聚簇索引特点
                    </h3>
                    <div class="space-y-4">
                        <div class="p-4 bg-white rounded-lg shadow-sm">
                            <p class="font-medium text-gray-800">数据存储方式</p>
                            <p class="text-gray-600 mt-1">索引的键值和实际数据行的存储顺序不一定一致。叶子节点保存的是指向对应数据行的指针。</p>
                        </div>
                        <div class="p-4 bg-white rounded-lg shadow-sm">
                            <p class="font-medium text-gray-800">查询过程</p>
                            <p class="text-gray-600 mt-1">需要先查找索引，然后根据索引中的指针找到对应的数据行，可能比聚簇索引稍慢。</p>
                        </div>
                        <div class="p-4 bg-white rounded-lg shadow-sm">
                            <p class="font-medium text-gray-800">数量限制</p>
                            <p class="text-gray-600 mt-1">一个表可以有多个非聚簇索引，可以根据实际需要创建不同的索引来优化查询。</p>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="image-container">
                <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1712203361001-0d92884e-298f-497e-a9cc-80fbd7da6a23.png" alt="索引对比图" class="w-full">
                <div class="image-caption">聚簇索引与非聚簇索引对比示意图</div>
            </div>
        </section>

        <!-- Storage Structure -->
        <section id="storage" class="mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 border-l-4 border-blue-500 pl-4">存储结构</h2>
            
            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div>
                    <h3 class="text-2xl font-semibold text-gray-800 mb-4">聚簇索引存储结构</h3>
                    <p class="text-gray-600 mb-4">聚簇索引的数据行存储在索引的叶子节点中，因此索引的叶子节点即为数据行。这意味着聚簇索引实际上就是对整个表的重新组织，根据索引的键值将数据行按照顺序存储。</p>
                    <div class="highlight-box p-4">
                        <p class="font-medium">关键点：</p>
                        <ul class="list-disc pl-5 space-y-1 mt-2">
                            <li>数据行和索引存储在同一结构中</li>
                            <li>物理存储顺序与逻辑顺序一致</li>
                            <li>B+树的叶子节点包含完整数据行</li>
                        </ul>
                    </div>
                </div>
                
                <div class="image-container">
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1712203453789-e31a58bb-0a3c-4405-a69c-5408f5d3cd44.png" alt="聚簇索引存储结构" class="w-full">
                    <div class="image-caption">聚簇索引存储结构示意图</div>
                </div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="order-2 md:order-1">
                    <div class="image-container">
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1712203506282-eb168214-14cd-4dbf-a781-42434e457bd3.png" alt="非聚簇索引存储结构" class="w-full">
                        <div class="image-caption">非聚簇索引存储结构示意图</div>
                    </div>
                </div>
                
                <div class="order-1 md:order-2">
                    <h3 class="text-2xl font-semibold text-gray-800 mb-4">非聚簇索引存储结构</h3>
                    <p class="text-gray-600 mb-4">非聚簇索引的存储结构与聚簇索引有所不同。在非聚簇索引中，索引的叶子节点保存了指向对应数据行的指针，而数据行的存储则是按照数据库的物理存储顺序进行的。</p>
                    <div class="highlight-box p-4">
                        <p class="font-medium">关键点：</p>
                        <ul class="list-disc pl-5 space-y-1 mt-2">
                            <li>索引和数据行分开存储</li>
                            <li>叶子节点包含指向数据行的指针</li>
                            <li>查询时需要"回表"操作</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- Use Cases -->
        <section id="usecases" class="mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 border-l-4 border-blue-500 pl-4">使用场景</h2>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-12">
                <div class="grid md:grid-cols-2">
                    <div class="p-8 border-b md:border-b-0 md:border-r border-gray-200">
                        <h3 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
                            <div class="w-10 h-10 rounded-lg bg-blue-100 flex items-center justify-center mr-4">
                                <i class="fas fa-sitemap text-blue-500"></i>
                            </div>
                            聚簇索引适用场景
                        </h3>
                        <ul class="space-y-4">
                            <li class="flex items-start">
                                <div class="flex-shrink-0 mt-1">
                                    <div class="w-6 h-6 rounded-full bg-blue-100 flex items-center justify-center">
                                        <i class="fas fa-search text-blue-500 text-xs"></i>
                                    </div>
                                </div>
                                <div class="ml-3">
                                    <p class="font-medium text-gray-800">范围查询</p>
                                    <p class="text-gray-600 mt-1">适合经常需要执行范围查询的情况，因为数据行按照主键顺序存储。</p>
                                </div>
                            </li>
                            <li class="flex items-start">
                                <div class="flex-shrink-0 mt-1">
                                    <div class="w-6 h-6 rounded-full bg-blue-100 flex items-center justify-center">
                                        <i class="fas fa-key text-blue-500 text-xs"></i>
                                    </div>
                                </div>
                                <div class="ml-3">
                                    <p class="font-medium text-gray-800">主键查询</p>
                                    <p class="text-gray-600 mt-1">适合频繁进行主键查询的场景，可以直接定位数据行。</p>
                                </div>
                            </li>
                            <li class="flex items-start">
                                <div class="flex-shrink-0 mt-1">
                                    <div class="w-6 h-6 rounded-full bg-blue-100 flex items-center justify-center">
                                        <i class="fas fa-sort-amount-up text-blue-500 text-xs"></i>
                                    </div>
                                </div>
                                <div class="ml-3">
                                    <p class="font-medium text-gray-800">排序操作</p>
                                    <p class="text-gray-600 mt-1">需要按照主键顺序排序时性能高效。</p>
                                </div>
                            </li>
                        </ul>
                    </div>
                    
                    <div class="p-8">
                        <h3 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
                            <div class="w-10 h-10 rounded-lg bg-purple-100 flex items-center justify-center mr-4">
                                <i class="fas fa-project-diagram text-purple-500"></i>
                            </div>
                            非聚簇索引适用场景
                        </h3>
                        <ul class="space-y-4">
                            <li class="flex items-start">
                                <div class="flex-shrink-0 mt-1">
                                    <div class="w-6 h-6 rounded-full bg-purple-100 flex items-center justify-center">
                                        <i class="fas fa-random text-purple-500 text-xs"></i>
                                    </div>
                                </div>
                                <div class="ml-3">
                                    <p class="font-medium text-gray-800">随机访问</p>
                                    <p class="text-gray-600 mt-1">适合经常需要进行随机访问的情况。</p>
                                </div>
                            </li>
                            <li class="flex items-start">
                                <div class="flex-shrink-0 mt-1">
                                    <div class="w-6 h-6 rounded-full bg-purple-100 flex items-center justify-center">
                                        <i class="fas fa-clipboard-check text-purple-500 text-xs"></i>
                                    </div>
                                </div>
                                <div class="ml-3">
                                    <p class="font-medium text-gray-800">覆盖索引</p>
                                    <p class="text-gray-600 mt-1">查询所需的列都包含在索引中时，无需访问数据行。</p>
                                </div>
                            </li>
                            <li class="flex items-start">
                                <div class="flex-shrink-0 mt-1">
                                    <div class="w-6 h-6 rounded-full bg-purple-100 flex items-center justify-center">
                                        <i class="fas fa-calculator text-purple-500 text-xs"></i>
                                    </div>
                                </div>
                                <div class="ml-3">
                                    <p class="font-medium text-gray-800">聚集数据</p>
                                    <p class="text-gray-600 mt-1">对特定列进行SUM、AVG等聚集操作时性能更好。</p>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            
            <!-- Mermaid Diagram -->
            <div class="mermaid">
                graph TD
                    A[查询需求] --> B{是主键查询?}
                    B -->|是| C[使用聚簇索引]
                    B -->|否| D{需要范围查询?}
                    D -->|是| C
                    D -->|否| E{需要排序?}
                    E -->|是| C
                    E -->|否| F[考虑非聚簇索引]
                    F --> G{索引覆盖查询?}
                    G -->|是| H[使用非聚簇索引]
                    G -->|否| I[评估回表成本]
            </div>
        </section>

        <!-- Primary Key Relationship -->
        <section id="primarykey" class="mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 border-l-4 border-blue-500 pl-4">主键和聚簇索引的关系</h2>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                <div class="p-8">
                    <div class="flex items-center mb-6">
                        <div class="w-12 h-12 rounded-lg bg-indigo-100 flex items-center justify-center mr-4">
                            <i class="fas fa-link text-indigo-500 text-xl"></i>
                        </div>
                        <h3 class="text-2xl font-semibold text-gray-800">聚簇索引与主键的紧密联系</h3>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-8">
                        <div>
                            <p class="text-gray-600 mb-4">在大多数数据库系统中，当我们在表中定义主键时，系统会自动为该主键创建一个聚簇索引。聚簇索引按照主键的顺序组织数据，实际上对应于表的物理存储方式。</p>
                            <div class="bg-gray-50 p-4 rounded-lg">
                                <p class="font-medium text-gray-800">关键关系：</p>
                                <p class="text-gray-600 mt-2">主键是唯一标识每一行数据的索引键，而聚簇索引则是按照主键顺序组织数据行的物理存储结构。</p>
                            </div>
                        </div>
                        
                        <div class="image-container">
                            <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1712203711881-bb3c529b-65f1-4adf-989a-0c4fd02a192b.png" alt="主键与聚簇索引关系" class="w-full">
                            <div class="image-caption">主键与聚簇索引关系示意图</div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="grid md:grid-cols-3 gap-6">
                <div class="bg-white p-6 rounded-lg shadow-sm">
                    <div class="w-10 h-10 rounded-lg bg-blue-100 flex items-center justify-center mb-4">
                        <i class="fas fa-bolt text-blue-500"></i>
                    </div>
                    <h4 class="font-semibold text-gray-800 mb-2">查询性能</h4>
                    <p class="text-gray-600 text-sm">聚簇索引使主键查询效率极高，数据库可以直接根据主键值定位数据行。</p>
                </div>
                
                <div class="bg-white p-6 rounded-lg shadow-sm">
                    <div class="w-10 h-10 rounded-lg bg-purple-100 flex items-center justify-center mb-4">
                        <i class="fas fa-unlink text-purple-500"></i>
                    </div>
                    <h4 class="font-semibold text-gray-800 mb-2">非主键索引</h4>
                    <p class="text-gray-600 text-sm">非主键索引不会自动创建聚簇索引，一个表可以有多个非主键索引。</p>
                </div>
                
                <div class="bg-white p-6 rounded-lg shadow-sm">
                    <div class="w-10 h-10 rounded-lg bg-green-100 flex items-center justify-center mb-4">
                        <i class="fas fa-database text-green-500"></i>
                    </div>
                    <h4 class="font-semibold text-gray-800 mb-2">存储影响</h4>
                    <p class="text-gray-600 text-sm">聚簇索引影响数据的物理存储方式，而非聚簇索引不会。</p>
                </div>
            </div>
        </section>

        <!-- Performance Impact -->
        <section id="performance" class="mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 border-l-4 border-blue-500 pl-4">性能影响</h2>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                <div class="p-8">
                    <div class="flex items-center mb-6">
                        <div class="w-12 h-12 rounded-lg bg-red-100 flex items-center justify-center mr-4">
                            <i class="fas fa-tachometer-alt text-red-500 text-xl"></i>
                        </div>
                        <h3 class="text-2xl font-semibold text-gray-800">索引类型对数据库性能的影响</h3>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-8">
                        <div>
                            <h4 class="text-xl font-semibold text-gray-800 mb-3 flex items-center">
                                <div class="w-8 h-8 rounded-full bg-blue-100 flex items-center justify-center mr-3">
                                    <i class="fas fa-sitemap text-blue-500 text-sm"></i>
                                </div>
                                聚簇索引性能特点
                            </h4>
                            <ul class="space-y-3">
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 mt-1">
                                        <div class="w-5 h-5 rounded-full bg-blue-100 flex items-center justify-center">
                                            <i class="fas fa-plus text-blue-500 text-xs"></i>
                                        </div>
                                    </div>
                                    <div class="ml-3">
                                        <p class="font-medium text-gray-800">主键查询高效</p>
                                        <p class="text-gray-600 text-sm mt-1">直接根据主键值定位数据行，无需额外查找</p>
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 mt-1">
                                        <div class="w-5 h-5 rounded-full bg-blue-100 flex items-center justify-center">
                                            <i class="fas fa-plus text-blue-500 text-xs"></i>
                                        </div>
                                    </div>
                                    <div class="ml-3">
                                        <p class="font-medium text-gray-800">范围查询高效</p>
                                        <p class="text-gray-600 text-sm mt-1">利用索引的顺序性高效执行范围查询</p>
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 mt-1">
                                        <div class="w-5 h-5 rounded-full bg-red-100 flex items-center justify-center">
                                            <i class="fas fa-minus text-red-500 text-xs"></i>
                                        </div>
                                    </div>
                                    <div class="ml-3">
                                        <p class="font-medium text-gray-800">插入/删除影响</p>
                                        <p class="text-gray-600 text-sm mt-1">可能导致数据物理重排，影响性能</p>
                                    </div>
                                </li>
                            </ul>
                        </div>
                        
                        <div>
                            <h4 class="text-xl font-semibold text-gray-800 mb-3 flex items-center">
                                <div class="w-8 h-8 rounded-full bg-purple-100 flex items-center justify-center mr-3">
                                    <i class="fas fa-project-diagram text-purple-500 text-sm"></i>
                                </div>
                                非聚簇索引性能特点
                            </h4>
                            <ul class="space-y-3">
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 mt-1">
                                        <div class="w-5 h-5 rounded-full bg-purple-100 flex items-center justify-center">
                                            <i class="fas fa-plus text-purple-500 text-xs"></i>
                                        </div>
                                    </div>
                                    <div class="ml-3">
                                        <p class="font-medium text-gray-800">随机访问高效</p>
                                        <p class="text-gray-600 text-sm mt-1">快速根据索引键值查找数据行指针</p>
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 mt-1">
                                        <div class="w-5 h-5 rounded-full bg-purple-100 flex items-center justify-center">
                                            <i class="fas fa-plus text-purple-500 text-xs"></i>
                                        </div>
                                    </div>
                                    <div class="ml-3">
                                        <p class="font-medium text-gray-800">覆盖索引高效</p>
                                        <p class="text-gray-600 text-sm mt-1">查询完全通过索引执行，不访问数据行</p>
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 mt-1">
                                        <div class="w-5 h-5 rounded-full bg-red-100 flex items-center justify-center">
                                            <i class="fas fa-minus text-red-500 text-xs"></i>
                                        </div>
                                    </div>
                                    <div class="ml-3">
                                        <p class="font-medium text-gray-800">回表操作成本</p>
                                        <p class="text-gray-600 text-sm mt-1">需要额外IO操作访问数据行</p>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Performance Comparison Table -->
            <div class="overflow-x-auto bg-white rounded-lg shadow-md">
                <table class="min-w-full comparison-table">
                    <thead>
                        <tr>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">性能指标</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">聚簇索引</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">非聚簇索引</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-200">
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800">主键查询</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
                                    极优
                                </span>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800">
                                    良好
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800">范围查询</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
                                    极优
                                </span>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800">
                                    一般
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800">随机访问</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
                                    极优
                                </span>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
                                    极优
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800">插入操作</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800">
                                    较慢
                                </span>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
                                    快速
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800">存储空间</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800">
                                    中等
                                </span>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
                                    较小
                                </span>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </section>

        <!-- Technical Deep Dive -->
        <section id="technical" class="mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 border-l-4 border-blue-500 pl-4">技术深度解析</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <div class="bg-white p-6 rounded-xl shadow-md mb-8">
                        <h3 class="text-2xl font-semibold text-gray-800 mb-4">聚簇索引技术细节</h3>
                        <p class="text-gray-600 mb-4">将数据存储与索引放到了一块，<strong>索引结构的叶子节点保存了行数据的B+树称为聚簇索引</strong>。</p>
                        <p class="text-gray-600 mb-4"><strong>InnoDB使用的是聚簇索引，将主键按大小排序规则建立的B+树中</strong>，若使用"where id = 14"这样的条件查找主键，则按照B+树的检索算法即可查找到对应的叶节点，之后获得行数据。</p>
                        <div class="image-container">
                            <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1653815844934-67995283-8a5b-41a0-b289-26bf9d352b7f.png?x-oss-process=image%2Fresize%2Cw_331%2Climit_0%2Fresize%2Cw_331%2Climit_0" alt="聚簇索引B+树结构" class="w-full">
                            <div class="image-caption">聚簇索引的B+树结构</div>
                        </div>
                    </div>
                </div>
                
                <div>
                    <div class="bg-white p-6 rounded-xl shadow-md mb-8">
                        <h3 class="text-2xl font-semibold text-gray-800 mb-4">非聚簇索引技术细节</h3>
                        <p class="text-gray-600 mb-4">了解完聚簇索引后我们不难发现，聚簇索引只能在主键搜索时才能发挥作用。我们可以创建多颗B+树，且不同B+树中的数据采用不同的排序规则。</p>
                        <p class="text-gray-600 mb-4">非聚簇索引<strong>将数据与索引分开存储，索引结构的叶子节点指向了数据对应的位置</strong>。若对Name列进行条件搜索，则需要两个步骤：</p>
                        <ol class="list-decimal pl-5 space-y-2 text-gray-600">
                            <li><strong>第一步</strong>在辅助索引B+树中检索Name，到达其叶子节点获取对应的主键。</li>
                            <li><strong>第二步</strong>使用主键在聚簇索引中再执行一次B+树检索操作，最终到达叶子节点即可获取整行数据(称为<strong>回表</strong>)。</li>
                        </ol>
                        <div class="image-container mt-4">
                            <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1653815929512-c5ea9f64-bda9-4726-a0b3-ebe5d2184956.png?x-oss-process=image%2Fresize%2Cw_631%2Climit_0%2Fresize%2Cw_631%2Climit_0" alt="非聚簇索引B+树结构" class="w-full">
                            <div class="image-caption">非聚簇索引的B+树结构</div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="bg-white p-6 rounded-xl shadow-md">
                <h3 class="text-2xl font-semibold text-gray-800 mb-4">InnoDB与MyISAM索引实现对比</h3>
                <div class="grid md:grid-cols-2 gap-6">
                    <div>
                        <div class="flex items-center mb-3">
                            <div class="w-8 h-8 rounded-full bg-blue-100 flex items-center justify-center mr-3">
                                <i class="fas fa-database text-blue-500 text-sm"></i>
                            </div>
                            <h4 class="text-xl font-semibold text-gray-800">InnoDB</h4>
                        </div>
                        <ul class="list-disc pl-5 space-y-2 text-gray-600">
                            <li>使用聚簇索引组织数据</li>
                            <li>主键查询效率极高</li>
                            <li>支持事务和行级锁</li>
                            <li>聚簇索引叶子节点存储完整数据</li>
                            <li>辅助索引需要回表操作</li>
                        </ul>
                    </div>
                    
                    <div>
                        <div class="flex items-center mb-3">
                            <div class="w-8 h-8 rounded-full bg-purple-100 flex items-center justify-center mr-3">
                                <i class="fas fa-database text-purple-500 text-sm"></i>
                            </div>
                            <h4 class="text-xl font-semibold text-gray-800">MyISAM</h4>
                        </div>
                        <ul class="list-disc pl-5 space-y-2 text-gray-600">
                            <li>使用非聚簇索引</li>
                            <li>索引和数据分开存储</li>
                            <li>不支持事务和行级锁</li>
                            <li>索引叶子节点存储数据指针</li>
                            <li>所有索引查询方式相同</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- No Primary Key Scenario -->
        <section id="nopk" class="mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 border-l-4 border-blue-500 pl-4">没有主键的情况</h2>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-8">
                    <div class="flex items-center mb-6">
                        <div class="w-12 h-12 rounded-lg bg-orange-100 flex items-center justify-center mr-4">
                            <i class="fas fa-exclamation-triangle text-orange-500 text-xl"></i>
                        </div>
                        <h3 class="text-2xl font-semibold text-gray-800">表中没有主键会发生什么？</h3>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-8">
                        <div>
                            <p class="text-gray-600 mb-4">在MySQL的InnoDB引擎中，如果表没有显式定义主键，并且也没有合适的唯一索引，那么InnoDB会自动为每一行记录生成一个隐藏的聚簇索引，该索引的内容类似于一个隐藏的主键。</p>
                            <div class="bg-orange-50 p-4 rounded-lg border border-orange-100">
                                <p class="font-medium text-orange-800">注意：</p>
                                <p class="text-orange-700 text-sm mt-2">这个隐藏的聚簇索引的字段通常被称为ROWID、DB_ROW_ID、或GEN_CLUST_INDEX，具体名称可能取决于MySQL版本和数据库引擎。它是一个内部生成的、对用户不可见的字段，用于唯一标识表中的每一行记录。</p>
                            </div>
                        </div>
                        
                        <div class="image-container">
                            <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1712203889413-52ce6930-d601-4386-a1ef-167cb109b8ff.png" alt="无主键时的隐藏索引" class="w-full">
                            <div class="image-caption">无主键时的隐藏聚簇索引</div>
                        </div>
                    </div>
                    
                    <div class="mt-8 bg-gray-50 p-6 rounded-lg">
                        <h4 class="text-xl font-semibold text-gray-800 mb-4">最佳实践建议</h4>
                        <ul class="list-disc pl-5 space-y-2 text-gray-600">
                            <li>始终为表定义显式主键，而不是依赖自动生成的隐藏主键</li>
                            <li>选择简单、短小的数据类型作为主键(如自增整数)</li>
                            <li>避免使用可变的或长字符串作为主键</li>
                            <li>如果确实不需要主键，至少定义一个唯一索引</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section id="summary" class="mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 border-l-4 border-blue-500 pl-4">总结与最佳实践</h2>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-8">
                    <div class="flex flex-col md:flex-row">
                        <div class="md:w-1/2 md:pr-8 mb-8 md:mb-0">
                            <h3 class="text-2xl font-semibold text-gray-800 mb-4">核心区别总结</h3>
                            <div class="space-y-4">
                                <div class="p-4 bg-gray-50 rounded-lg">
                                    <p class="font-medium text-gray-800">存储结构</p>
                                    <p class="text-gray-600 mt-2">聚簇索引的叶子节点存储数据行，非聚簇索引的叶子节点存储数据指针。</p>
                                </div>
                                <div class="p-4 bg-gray-50 rounded-lg">
                                    <p class="font-medium text-gray-800">数量限制</p>
                                    <p class="text-gray-600 mt-2">一个表只能有一个聚簇索引，但可以有多个非聚簇索引。</p>
                                </div>
                                <div class="p-4 bg-gray-50 rounded-lg">
                                    <p class="font-medium text-gray-800">查询性能</p>
                                    <p class="text-gray-600 mt-2">聚簇索引的主键查询效率最高，非聚簇索引可能需回表操作。</p>
                                </div>
                            </div>
                        </div>
                        
                        <div class="md:w-1/2 md:pl-8">
                            <h3 class="text-2xl font-semibold text-gray-800 mb-4">索引选择最佳实践</h3>
                            <div class="space-y-4">
                                <div class="flex items-start">
                                    <div class="flex-shrink-0 mt-1">
                                        <div class="w-6 h-6 rounded-full bg-blue-100 flex items-center justify-center">
                                            <i class="fas fa-check-circle text-blue-500 text-xs"></i>
                                        </div>
                                    </div>
                                    <div class="ml-3">
                                        <p class="font-medium text-gray-800">选择合适的主键</p>
                                        <p class="text-gray-600 text-sm mt-1">使用简单、短小的数据类型作为主键(如自增整数)。</p>
                                    </div>
                                </div>
                                <div class="flex items-start">
                                    <div class="flex-shrink-0 mt-1">
                                        <div class="w-6 h-6 rounded-full bg-blue-100 flex items-center justify-center">
                                            <i class="fas fa-check-circle text-blue-500 text-xs"></i>
                                        </div>
                                    </div>
                                    <div class="ml-3">
                                        <p class="font-medium text-gray-800">聚簇索引使用</p>
                                        <p class="text-gray-600 text-sm mt-1">将聚簇索引用于最频繁的主键查询和范围查询场景。</p>
                                    </div>
                                </div>
                                <div class="flex items-start">
                                    <div class="flex-shrink-0 mt-1">
                                        <div class="w-6 h-6 rounded-full bg-blue-100 flex items-center justify-center">
                                            <i class="fas fa-check-circle text-blue-500 text-xs"></i>
                                        </div>
                                    </div>
                                    <div class="ml-3">
                                        <p class="font-medium text-gray-800">非聚簇索引使用</p>
                                        <p class="text-gray-600 text-sm mt-1">为常用查询条件创建非聚簇索引，尽量设计覆盖索引。</p>
                                    </div>
                                </div>
                                <div class="flex items-start">
                                    <div class="flex-shrink-0 mt-1">
                                        <div class="w-6 h-6 rounded-full bg-blue-100 flex items-center justify-center">
                                            <i class="fas fa-check-circle text-blue-500 text-xs"></i>
                                        </div>
                                    </div>
                                    <div class="ml-3">
                                        <p class="font-medium text-gray-800">避免过度索引</p>
                                        <p class="text-gray-600 text-sm mt-1">索引会增加存储开销和写入成本，只创建必要的索引。</p>
                                    </div>
                                </div>
                                <div class="flex items-start">
                                    <div class="flex-shrink-0 mt-1">
                                        <div class="w-6 h-6 rounded-full bg-blue-100 flex items-center justify-center">
                                            <i class="fas fa-check-circle text-blue-500 text-xs"></i>
                                        </div>
                                    </div>
                                    <div class="ml-3">
                                        <p class="font-medium text-gray-800">定期维护</p>
                                        <p class="text-gray-600 text-sm mt-1">定期分析和优化索引，删除无用索引，重建碎片化索引。</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12">
        <div class="container mx-auto px-6 max-w-6xl">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-6 md:mb-0">
                    <h3 class="text-xl font-semibold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">探索技术世界的知识宝库</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-300 flex items-center">
                        <i class="fas fa-globe mr-2"></i> http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-500 text-sm">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```